package com.sikaryofficial.information.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author : qinjinyuan
 * @desc : 文章标签枚举
 * <p>
 * `article_lable` tinyint unsigned DEFAULT '0' COMMENT '文章标签:0-其他,1-小口吸,2-大口吸,3-Event',
 * @date : 2023/11/04 10:08
 */
@Getter
@AllArgsConstructor
public enum ArticleLabelEnum {

    OTHER(0, "其他"),
    SMALL_MOUTH(1, "小口数"),
    BIG_MOUTH(2, "大口数"),
    EVENT(3, "Event"),
    ;
    private final Integer code;
    private final String name;

    public static ArticleLabelEnum getNameByCode(Integer code) {

        return Arrays.stream(ArticleLabelEnum.values())
                .filter(pointRuleEnum -> Objects.nonNull(code) && pointRuleEnum.getCode().equals(code))
                .findFirst().orElse(null);

    }
}
